/*
 * @Author: RidingWind
 * @Info: 弱提示框
 * @Date: 2018-02-27 11:09:23
 * @Last Modified by: 大招科技 - RidingWind
 * @Last Modified time: 2018-02-27 13:42:56
 */

import $ from 'jquery';

const dom = document.createElement('div');
dom.id = 'toast-div';
document.body.appendChild(dom);
const toast = $(dom);

const TOAST = {
  show(text, option) {
    const mOption = option || {};
    const fadeIn = mOption.fadeIn || 400;
    const delay = mOption.delay || 1000;
    const fadeOut = mOption.fadeOut || 400;
    const bottom = mOption.bottom || '50%';
    toast.css({
      width: '400px',
      display: 'none',
      position: 'fixed',
      left: '50%',
      'margin-left': '-200px',
      'line-height': '1.8',
      bottom,
      'background-color': '#666',
      color: '#F0F0F0',
      'font-size': '15px',
      'box-sizing': 'border-box',
      padding: '10px 20px 10px 20px',
      'text-align': 'center',
      'border-radius': '5px',
      '-webkit-box-shadow': '0px 0px 24px -1px rgba(56, 56, 56, 1)',
      '-moz-box-shadow': '0px 0px 24px -1px rgba(56, 56, 56, 1)',
      'box-shadow': '0px 0px 24px -1px rgba(56, 56, 56, 1)',
      'z-index': 100000,
    });
    if (text) {
      toast.html(text);
      toast.stop().fadeIn(fadeIn).delay(delay).fadeOut(fadeOut);
    }
  },
};

export default TOAST;
